
function initEvents() {
    videoInfo = document.getElementById('videoInfo');
    videoInfo.hidden = true;
  $('#login-btn').click(function() {
      loginAttempt();
  });
  
}

function showProfilePic(url) {
  $('#profile-pic').append('<img src="'+url+'" width="40" height="40"></img>');
}

function showPubStations(sList)
{
    var sDiv = document.getElementById('stationPubList');
    clearChildren(sDiv);
    var title = document.createElement('h2')
    title.appendChild(document.createTextNode('Public Stations'))
    sDiv.appendChild(title);
    appendListOfStations(sDiv,sList);
}

function showPrivStations(sList)
{
    var sDiv = document.getElementById('stationPrivList');
    clearChildren(sDiv);
    var title = document.createElement('h2')
    title.appendChild(document.createTextNode('Your Stations'))
    sDiv.appendChild(title);
    appendListOfStations(sDiv,sList);
}


function showFacebookName(name) {
    $('#profile-name').append(name);
}

function hideLogin() {
$('#login').hide();
}


function clearChildren(node) {
    if ( node.hasChildNodes() ) {
        while ( node.childNodes.length >= 1 ) {
            node.removeChild( node.firstChild );
        }
    }

}

function appendListOfStations(sDiv,sList)
{
    var ulEl = document.createElement('ul');
    var nKids = sList.length;
    for (var i = 0, station;station = sList[i]; i++)
    {
	var child = document.createElement('li');
	child.appendChild(document.createTextNode(station.station_name));
	child.setAttribute('name',station.station_key);
	child.setAttribute('onClick', "stationSelected(this)");
	ulEl.appendChild(child);
    }
    sDiv.appendChild(ulEl);
    return;
}

function updateAndShowVideoInfo(title)
{
    alert('hello');
    videoTitle = document.getElementById('videoTitle');
    videoTitle.innerText = title;
    videoInfo = document.getElementById('videoInfo');
    videoInfo.hidden = false;
}
